import socket

s = socket.socket()

host = '127.0.0.1'
port = 2000

s.connect((host,port))

ip, port = s.getsockname()

if __name__ == '__main__':
    print('ip and port are{} {}'.format(ip, port))

    # 只能发一次 发第二次卡主 现在会不知道怎么解决
    while True:

        http_request = input('input request')

        request = http_request.encode('utf-8')

        print('请求', request)

        s.send(request)

        response = s.recv(1023)

        print('响应的 str 格式', response.decode('utf-8'))

